<template>
<div>
  <div class="myBox" @click="info">
    <div class="L"><img :src="avatar" /></div>
    <div class="C">
      <div class="tit">{{ username }}</div>
      <div class="sub">注册日期-----{{ time }}</div>
    </div>
    <div class="R"><img src="assets/images/go.png" /></div>
  </div>
<div class="clear"></div>
<div class="allkbox"></div>
<div class="myboxcon" v-for="(item, index) in list" :key="item.id" @click="listClick(index)">
  <p>{{ item.listName }}</p>
  <img src="assets/images/go.png">
</div>
<div class="myboxcon" @click="send()">
  <p>注销</p>
  <img src="assets/images/go.png">
</div>


<Footer></Footer>
</div>
</template>

<script>
import Footer from 'components/common/Footer.vue';
import { showSuccessToast,showDialog, showToast , showFailToast} from 'vant';
export default {
  // setup(props) {
    
  // },
  data() {
    return {
      avatar: this.$cookies.get('User').avatar_text,
      username: this.$cookies.get('User').nickname_text,
      time: this.$cookies.get('User').createtime,
      list: [
        {
          id: 1,
          listName: '基本资料',
          path: '/business/change'
        },
        {
          id: 2,
          listName: '邮箱认证',
          path: '/business/email'
        },
        {
          id: 3,
          listName: '收货地址',
          path: '/address'
        },
        {
          id: 4,
          listName: '我的订单',
          path: '/business/order'
        },
        {
          id: 5,
          listName: '消费记录',
          path: '/business/record'
        },
        {
          id: 6,
          listName: '充值中心',
          path: '/business/pay'
        },
        {
          id: 7,
          listName: '充值记录',
          path: '/business/payrecord'
        }
      ]
    }
  },
  components:{
    Footer
  },
  methods:{
    // 退出登入
    send(){
      showDialog({
        title: '退出',
        message: '确定要退出吗',
        showCancelButton: true
      }).then(() => {
        // 删除cookies信息
        this.$cookies.remove('User');
        showSuccessToast({ message: "退出成功" });
        this.$router.push('/business/login');
      });
    },
    // 信息修改页
    info(){
      this.$router.push('/business/change');
    },
    listClick(index){
      if (index == 1) {
        if (this.$cookies.get('User').auth == 1) {
          this.$router.push('/business');
          showToast({
            message: "邮箱已认证，需要更改请在信息页修改",
            time: 5*1000
          });
          return;
        }
      }
      if (this.list[index].path) {
        this.$router.push(this.list[index].path);
      }
    }
  }
}
</script>

<style lang="less" scoped>
.myboxcon{
  cursor: pointer;
  & > p {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
img{
  object-fit: cover;
  object-position: center;
}
</style>